import { USER_AUTH } from '@/store/mutation-types'
const columns = [
  {
    title: '手机号',
    dataIndex: 'phone',
    align: 'center',
    fixed: 'left',
    width: 150
  },
  {
    title: '昵称',
    dataIndex: 'nickName',
    align: 'center',
    fixed: 'left',
    width: 200,
    scopedSlots: { customRender: 'nickName' }
  },
  {
    title: '订阅状态',
    dataIndex: 'userRightStatus',
    align: 'left',
    width: 150,
    scopedSlots: { customRender: 'userRightStatus' }
  },
  {
    title: '剩余BOX',
    dataIndex: 'remainNum',
    align: 'left',
    width: 120
  },
  {
    title: '累计服务次数',
    dataIndex: 'totAskBox',
    align: 'left',
    width: 120
  },
  /* {
    title: '累计购买金额',
    dataIndex: 'totActualAmount',
    align: 'center',
    width: 150
  }, */
  {
    title: '累计BOX消费',
    dataIndex: 'boxTotConsume',
    align: 'left',
    width: 150
  },
  {
    title: '会员卡等级',
    dataIndex: 'vipTypeName',
    align: 'left',
    width: 150
  },
  {
    title: '订阅来源',
    dataIndex: 'subType',
    align: 'left',
    scopedSlots: { customRender: 'subType' },
    width: 150
  },
  // {
  //   title: '会员标签',
  //   dataIndex: 'tags',
  //   align: 'center',
  //   width: 150,
  //   scopedSlots: { customRender: 'tags' }
  // },
  {
    title: '备注',
    dataIndex: 'bgRemark',
    align: 'left',
    scopedSlots: { customRender: 'remark' },
    width: 150
  },
  /* {
    title: '注册时间',
    dataIndex: 'createTime',
    align: 'center',
    width: 150,
    scopedSlots: { customRender: 'createTime' }
  },
  {
    title: '最近一次订阅时间',
    dataIndex: 'startTime',
    align: 'center',
    width: 150,
    scopedSlots: { customRender: 'startTime' }
  },
  {
    title: '订阅到期时间',
    dataIndex: 'endTime',
    align: 'center',
    width: 150,
    scopedSlots: { customRender: 'endTime' }
  }, */
  {
    title: '操作',
    key: 'operation',
    width: '120px',
    align: 'center',
    fixed: 'right',
    scopedSlots: { customRender: 'action' }
  }
]
let isFashioner = null
let authList = JSON.parse(sessionStorage.getItem(USER_AUTH) || '[]')
if (authList.filter(e => e.action == 'customerList:notFashioner').length > 0) {
  isFashioner = false
} else {
  isFashioner = true
}
if (!isFashioner) {
  let gender = {
    title: '性别',
    dataIndex: 'gender',
    align: 'left',
    width: 150,
    scopedSlots: { customRender: 'gender' }
  }
  let fashioner = {
    title: '搭配师',
    dataIndex: 'fashionerName',
    align: 'left',
    width: 150
  }
  let fashionerType = {
    title: '搭配师类型',
    dataIndex: 'fashionerType',
    align: 'left',
    width: 120,
    scopedSlots: { customRender: 'fashionerType' }
  }
  columns.splice(2, 0, gender, fashionerType, fashioner)
}
const blackTime = {
  title: '加入黑名单时间',
  dataIndex: 'joinCategoryTime',
  align: 'left',
  width: 150,
}

const blackReason = {
  title: '黑名单原因',
  dataIndex: 'joinCategoryReason',
  align: 'left',
  width: 150
}

const blackColumns = JSON.parse(JSON.stringify(columns))

blackColumns.splice(-1, 0, blackTime, blackReason)

const specialTime = {
  title: '加入特殊名单时间',
  dataIndex: 'joinCategoryTime',
  align: 'left',
  width: 150
}

const specialReason = {
  title: '特殊原因',
  dataIndex: 'joinCategoryReason',
  align: 'left',
  width: 150
}

const specialColumns = JSON.parse(JSON.stringify(columns))

specialColumns.splice(-1, 0, specialTime, specialReason)

const statusMap = {
  0: {
    status: 'default',
    text: '未订阅'
  },
  1: {
    status: 'processing',
    text: '订阅中'
  },
  2: {
    status: 'success',
    text: '已过期'
  }
}

const fashionerMap = {
  0: {
    status: 'default',
    text: '搭配师'
  },
  1: {
    status: 'processing',
    text: '导购'
  }
}

import { getSubTypes } from '@/api/box/marketing'

export function fetchSubType () {
  return getSubTypes().then(res => {
    if (res.code == 0) {
      return res.data[0].children
    }
  })
}


const subType = {
  0: {
    text: '199购买服务'
  },
  1: {
    text: '积分抵扣兑换'
  },
  2: {
    text: '权益兑换'
  },
  3: {
    text: '兑换码兑换'
  },
  4: {
    text: '体验卡兑换（心意盒子）'
  },
  5: {
    text: '导购邀请'
  },
  6: {
    text: '金币兑换'
  },
  7: {
    text: '满送续订'
  },
  8: {
    text: '金卡0积分特权'
  },
  9: {
    text: '支付分免押'
  },
  10: {
    text: '0元白名单'
  },
  11: {
    text: '后台开通服务'
  }
}

export { columns, blackColumns, specialColumns, statusMap, fashionerMap, subType }
